package com.firmiana.jt809.entity;

import com.firmiana.jt809.service.BaseService;
import io.netty.channel.Channel;

import java.util.Date;

public class BizConnection {

    /**
     * netty session会话Id
     */
    private String sessionId;
    //接入码
    private String platformId;
    /**
     * 记录主链路的nettyChannel
     */
    private Channel nettyChannel;
    /**
     * 管理从链路的连接
     */
    private BaseService subLink;
    //下级平台服务器IP
    private String platformServerIp;
    //下级平台端口
    private int platformPort;
    //平台名称
    private String platformName;
    //连接时间
    private Date createDate;
    //最新在线时间
    private Date onlineDate;
    //收到的包的数量
    private int packageNum;
    //定位包数量
    private int positionPackageNum;
    //断开次数
    private int disconnectTimes;
    //错误包数
    private int errorPacketNum;
    //是否已连接
    private boolean connected;
    private boolean mainLinked;
    private boolean subLinked;

    public BizConnection(String _platformId, String sId) {
        this.platformId = _platformId;
        setSessionId(sId);
        setCreateDate(new Date());
        setOnlineDate(new Date());
    }

    public BizConnection(String _platformId) {
        this.platformId = _platformId;
        setCreateDate(new Date());
        setOnlineDate(new Date());
    }

    public BizConnection() {
        setCreateDate(new Date());
        setOnlineDate(new Date());
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getOnlineDate() {
        return onlineDate;
    }

    public void setOnlineDate(Date onlineDate) {
        this.onlineDate = onlineDate;
    }

    public boolean isConnected() {
        return connected;
    }

    public void setConnected(boolean connected) {
        this.connected = connected;
    }

    public int getErrorPacketNum() {
        return errorPacketNum;
    }

    public void setErrorPacketNum(int errorPacketNum) {
        this.errorPacketNum = errorPacketNum;
    }

    public int getDisconnectTimes() {
        return disconnectTimes;
    }

    public void setDisconnectTimes(int disconnectTimes) {
        this.disconnectTimes = disconnectTimes;
    }

    public int getPositionPackageNum() {
        return positionPackageNum;
    }

    public void setPositionPackageNum(int positionPackageNum) {
        this.positionPackageNum = positionPackageNum;
    }

    public int getPackageNum() {
        return packageNum;
    }

    public void setPackageNum(int packageNum) {
        this.packageNum = packageNum;
    }

    public String getPlatformId() {
        return platformId;
    }

    public void setPlatformId(String platformId) {
        this.platformId = platformId;
    }

    public String getPlatformName() {
        return platformName;
    }

    public void setPlatformName(String platformName) {
        this.platformName = platformName;
    }

    public boolean isMainLinked() {
        return mainLinked;
    }

    public void setMainLinked(boolean mainLinked) {
        this.mainLinked = mainLinked;
    }

    public boolean isSubLinked() {
        return subLinked;
    }

    public void setSubLinked(boolean subLinked) {
        this.subLinked = subLinked;
    }

    public Channel getNettyChannel() {
        return nettyChannel;
    }

    public void setNettyChannel(Channel nettyChannel) {
        this.nettyChannel = nettyChannel;
    }

    public String getPlatformServerIp() {
        return platformServerIp;
    }

    public void setPlatformServerIp(String platformServerIp) {
        this.platformServerIp = platformServerIp;
    }

    public int getPlatformPort() {
        return platformPort;
    }

    public void setPlatformPort(int platformPort) {
        this.platformPort = platformPort;
    }

    public BaseService getSubLink() {
        return subLink;
    }

    public void setSubLink(BaseService subLink) {
        this.subLink = subLink;
    }
}
